package com.orangelife.webservice.service.propApp.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
import java.util.Map;

public class ContentComparator implements Comparator<Map<String, Object>> {

	@Override
	public int compare(Map<String, Object> o1, Map<String, Object> o2) {
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		Date time1 = new Date();
		Date time2 = new Date();
		try {
			time1 = dateFormat.parse(o1.get("tscreate").toString());
			time2 = dateFormat.parse(o2.get("tscreate").toString());

		} catch (ParseException e) {

			e.printStackTrace();
		}

		if (time1.before(time2)) {
			return 1;
		} else if (time1.equals(time2)) {
			return 0;

		} else {
			return -1;
		}
	}

}
